"use strict";

const Sequelize = require("sequelize");

module.exports = (app) => {
  const { INTEGER, STRING, DATE } = Sequelize;
  const MenuModel = app.model.define(
    "menu",
    {
      id: {
        type: INTEGER,
        primaryKey: true,
        autoIncrement: true,
        comment: "菜单唯一标识符",
      },
      menuName: {
        field: "menu_name",
        type: STRING(30),
        allowNull: false,
        comment: "菜单名称",
      },
      menuParentId: {
        field: "menu_parent_id",
        type: INTEGER,
        allowNull: false,
        comment: "父级菜单id",
      },
      menuPath: {
        field: "menu_path",
        type: STRING(255),
        comment: "菜单路径",
      },
      menuRouterName: {
        field: "menu_router_name",
        type: STRING(255),
        allowNull: false,
        comment: "路由的name名称",
      },
      menuComponent: {
        field: "menu_component",
        type: STRING(255),
        allowNull: false,
        comment: "菜单组件",
      },
      menuIcon: {
        field: "menu_icon",
        type: STRING(100),
        allowNull: false,
        comment: "菜单图标",
      },
      menuType: {
        field: "menu_type",
        type: STRING(50),
        allowNull: false,
        comment: "菜单类型",
      },
      isShow: {
        field: "is_show",
        type: INTEGER,
        allowNull: false,
        comment: "是否显示",
      },
      createdAt: {
        field: "created_at",
        type: DATE,
        comment: "创建时间",
      },
      updatedAt: {
        field: "updated_at",
        type: DATE,
        comment: "更新时间",
      },
    },
    {
      tableName: "menu",
    }
  );

  return MenuModel;
};
